package com.fay.corejava.chapter4;

import java.util.ArrayList;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/1/31 16:44
 * @Version 1.0
 */
public class OverRidTest {
    public static void main(String[] args) {
//        testRid();

        Person person = new Person("Fred") {
            @Override
            public int getId() {
                return 12;
            }
        };
        Person fred = new Student("Fred", 12);
        System.out.println(person);
        System.out.println(fred);

        ArrayList<String> names = new ArrayList<String>(100){
            @Override
            public void add(int index, String element) {
                super.add(index, element);
                System.out.printf("Adding %s at %d\n ", element, index);
            }
        };
        names.add(1, "2");
    }

    private static void testRid() {
        Manager zx = new Manager("zx", 2000);
        zx.setBonus(1000);
        zx.raiseSalary(5);
        System.out.println(zx.getSalary());
    }
}
